Skip to content

[Frontend] Delegate tokenization serving preprocessing to OpenAIServingRender#37266

Merged
DarkLight1337 merged 2 commits intovllm-project:mainfrom
sagearc:delegate-openai-tokenization-to-renderer
Mar 17, 2026
Merged

[Frontend] Delegate tokenization serving preprocessing to OpenAIServingRender#37266
DarkLight1337 merged 2 commits intovllm-project:mainfrom
sagearc:delegate-openai-tokenization-to-renderer

Conversation

@sagearc
Copy link
Copy Markdown
Contributor

@sagearc sagearc commented Mar 17, 2026

Purpose

OpenAIServingRender (#36166) is the canonical, engine-free home for request preprocessing. #36483 wired it into OpenAIServingChat and OpenAIServingCompletion, but OpenAIServingTokenization was left calling the duplicate copies on OpenAIServing directly. This PR continues that cleanup by delegating tokenization serving preprocessing to OpenAIServingRender, and moves its construction to init_app_state so it's available to all serving classes from the start.

  1. OpenAIServingTokenization now delegates the following methods to openai_serving_render instead of calling the OpenAIServing base class copies:
    • _validate_chat_template
    • _preprocess_chat
    • _preprocess_completion
  2. OpenAIServingRender construction is moved out of init_generate_state into init_app_state so it's available earlier and shared across all serving classes.

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

…ngRender

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the initialization and usage of the OpenAIServingRender component. The OpenAIServingRender instance is now created centrally in api_server.py's init_app_state function, rather than in api_router.py's init_generate_state. Subsequently, the OpenAIServingTokenization service is updated to accept and utilize this OpenAIServingRender instance, delegating chat template validation and prompt preprocessing methods (_validate_chat_template, _preprocess_chat, _preprocess_completion) to it, thereby improving modularity and separation of concerns.

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) March 17, 2026 08:27
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 17, 2026
@DarkLight1337 DarkLight1337 merged commit 00f8e0d into vllm-project:main Mar 17, 2026
48 checks passed
@sagearc sagearc deleted the delegate-openai-tokenization-to-renderer branch March 17, 2026 11:23
Lucaskabela pushed a commit to Lucaskabela/vllm that referenced this pull request Mar 17, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
andylolu2 pushed a commit to andylolu2/vllm that referenced this pull request Mar 18, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
wendyliu235 pushed a commit to wendyliu235/vllm-public that referenced this pull request Mar 18, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
fxdawnn pushed a commit to fxdawnn/vllm that referenced this pull request Mar 19, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
khairulkabir1661 pushed a commit to khairulkabir1661/vllm that referenced this pull request Mar 27, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Monishver11 pushed a commit to Monishver11/vllm that referenced this pull request Mar 27, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Signed-off-by: Monishver Chandrasekaran <monishverchandrasekaran@gmail.com>
JiantaoXu pushed a commit to JiantaoXu/vllm that referenced this pull request Mar 28, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
vrdn-23 pushed a commit to vrdn-23/vllm that referenced this pull request Mar 30, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Signed-off-by: Vinay Damodaran <vrdn@hey.com>
EricccYang pushed a commit to EricccYang/vllm that referenced this pull request Apr 1, 2026
…ngRender (vllm-project#37266)

Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Signed-off-by: EricccYang <yangyang4991@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants